import App from './App'
import tools from '@/integralAdmin/utils/tools';
import http from '@/integralAdmin/request';
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
Vue.prototype.$tools= tools;
Vue.prototype.$http = http;
Vue.prototype.getDateymd = function(shijianchuo) {
	//shijianchuo是整数，否则要parseInt转换
	var shijianchuo = parseInt(shijianchuo) * 1000;
	var time = new Date(shijianchuo);
	console.log('time',time)
	var y = time.getFullYear();
	var m = time.getMonth() + 1;
	var d = time.getDate();
	var h = time.getHours();
	var mm = time.getMinutes();
	var s = time.getSeconds();
	return y + '-' + this.add0(m) + '-' + this.add0(d);
};


Vue.prototype.getDatehmm = function(shijianchuo) {
	//shijianchuo是整数，否则要parseInt转换
	var shijianchuo = parseInt(shijianchuo) * 1000;
	var time = new Date(shijianchuo);
	var y = time.getFullYear();
	var m = time.getMonth() + 1;
	var d = time.getDate();
	var h = time.getHours();
	var mm = time.getMinutes();
	var s = time.getSeconds();
	return this.add0(h) + ':' + this.add0(mm);
};
Vue.prototype.getDate = function(shijianchuo) {
	//shijianchuo是整数，否则要parseInt转换
	var shijianchuo = parseInt(shijianchuo) * 1000;
	var time = new Date(shijianchuo);
	var y = time.getFullYear();
	var m = time.getMonth() + 1;
	var d = time.getDate();
	var h = time.getHours();
	var mm = time.getMinutes();
	var s = time.getSeconds();
	return y + '-' + this.add0(m) + '-' + this.add0(d) + ' ' + this.add0(h) + ':' + this.add0(mm) + ':' + this.add0(
		s);
};
Vue.prototype.add0 = function(m) {
	return m < 10 ? '0' + m : m
};


//乘法函数，用来得到精确的乘法结果

//说明：javascript的乘法结果会有误差，在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。

//调用：accMul(arg1,arg2)

//返回值：arg1乘以arg2的精确结果

Vue.prototype.accMul = function(arg1, arg2) {

	var m = 0,
		s1 = arg1.toString(),
		s2 = arg2.toString();

	try {
		m += s1.split(".")[1].length
	} catch (e) {}

	try {
		m += s2.split(".")[1].length
	} catch (e) {}

	return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)

}

Vue.prototype.accDiv = function(arg1, arg2) {
	var t1 = 0,
		t2 = 0,
		r1, r2;
	try {
		t1 = arg1.toString().split(".")[1].length
	} catch (e) {}
	try {
		t2 = arg2.toString().split(".")[1].length
	} catch (e) {}
	Math.r1 = Number(arg1.toString().replace(".", ""))
	Math.r2 = Number(arg2.toString().replace(".", ""))
	return (Math.r1 / Math.r2) * Math.pow(10, t2 - t1);
}
// 加法
Vue.prototype.accAdd = function(arg1, arg2) {
	var r1, r2, m;
	try {
		r1 = arg1.toString().split(".")[1].length;
	} catch (e) {
		r1 = 0;
	}
	try {
		r2 = arg2.toString().split(".")[1].length;
	} catch (e) {
		r2 = 0;
	}
	m = Math.pow(10, Math.max(r1, r2));
	return (arg1 * m + arg2 * m) / m;
}
// 法
Vue.prototype.subtr = function(arg1, arg2) {
	var r1, r2, m, n;
	try {
		r1 = arg1.toString().split(".")[1].length;
	} catch (e) {
		r1 = 0;
	}
	try {
		r2 = arg2.toString().split(".")[1].length;
	} catch (e) {
		r2 = 0;
	}
	m = Math.pow(10, Math.max(r1, r2));
	//last modify by deeka
	//动态控制精度长度
	n = (r1 >= r2) ? r1 : r2;
	return ((arg1 * m - arg2 * m) / m).toFixed(n);
}


// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif